﻿<!--
 * @act      sina
 * @version  1.0
 * @author   xxxxx
 * @date     2018-03-18
 * youngxj提供接口
-->
<!DOCTYPE html>
<html lang="zh-cn"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>默笙云图床 - 免费保存图片，无限制保存，全网CDN加速，截图永久保存 - 免费图床 - 免费图床</title>
<meta name="description" content="永久免费图床，支持批量上传，即时预览，不限制流量，不限制外链数，永久保存，微博图片服务器，新浪图床，全网CDN图床，高速稳定,支持网页、手机上传，无需插件。支持JPG, GIF, PNG等文件格式。微博图床，围脖是个好图床。">
<meta name="keywords" content="打驴图床,图床API,图床,免费图床,微博图床,淘宝免费图床,淘宝图床,围脖是个好图床,围脖图床,网络图片,图片库,相册,网络相册">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link href="css/font-awesome.css" rel="stylesheet">
<link href="css/jumbotron-narrow.css" rel="stylesheet">
<link rel="shortcut icon" href="images/favicon.ico">
<link rel="bookmark" href="http://www.tecms.net/favicon.ico">
<style type="text/css">
    body{background:url(images/805406.jpg); background-size:cover;}
    .preview p{word-break: break-all; word-wrap:break-word;font-size:13px !important;}
</style>
<script src="js/yan.php"></script>
<!-- Piwik -->
<script type="text/javascript">
    var _paq = _paq || [];
    /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
    _paq.push(["setDocumentTitle", document.domain + "/" + document.title]);
    _paq.push(["setCookieDomain", "*.tools.youngxj.cn"]);
    _paq.push(["setDomains", ["*.tools.youngxj.cn"]]);
    _paq.push(['trackPageView']);
    _paq.push(['enableLinkTracking']);
    (function() {
      var u="//stat.yum6.cn/";
      _paq.push(['setTrackerUrl', u+'piwik.php']);
      _paq.push(['setSiteId', '2']);
      var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
      g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
  })();
</script>
<!-- End Piwik Code -->
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="/">默笙云图床</a>
            </div>
            <div id="navbar" class="navbar-collapse collapse">
                <ul class="nav navbar-nav">
                    <li class="active"><a href="/">Home</a></li>
                    <li><a href="http://www.tecms.net/">默笙官网</a></li>
                    <li><a href="http://www.iamy.vip/">小Y资源网</a></li>
                </ul>
            </div><!--/.nav-collapse -->
        </div><!--/.container-fluid -->
    </nav>
		<div class="jumbotron">
			</p>
			<div class="mselector">
				<input type="file" accept="image/*" multiple>
				<button type="button" class="btn btn-primary btn-sm">选择本地图片</button>
				<button type="button" class="btn btn-success btn-sm" data-toggle="modal" data-target="#url_upload_model">上传远程图片</button>
			</div>
			<hr>

			<textarea id="url-res-txt" class="form-control" rows="5" placeholder="上传后的图片外链地址将显示在此处哦、下方会同时显示外链地址和预览图。"></textarea>
			<div class="preview">
				<hr>
			</div>
		</div>
		
		<!-- url上传弹窗 -->
		<div id="url_upload_model" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
						<h4 class="modal-title" id="myModalLabel">上传远程图片</h4>
					</div>
					<div class="modal-body">
						<p class="lead">请在下方输入远程图片地址~每行一个~</p>
						<textarea class="form-control" name="urls" rows="3" id="urls"></textarea>
						<p id="urlUploadNotice"></p>
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
						<button type="button" class="btn btn-primary" onclick="url_upload();">上传</button>
					</div>
				</div>
			</div>
		</div>

		
		<div class="footer">
		</div>
	</div>
	<script src="js/jquery.min.js"></script>
	<script src="js/bootstrap.min.js"></script>
	<script type="text/javascript">
		$(document).ready(function() {
            $('.picurl > input').bind('focus mouseover', function() {
                if (this.value) {
                    this.select()
                }
            });
            $("input[type='file']").change(function(e) {
                images_upload(this.files)
            });
            var obj = $('body');
            obj.on('dragenter', function(e) {
                e.stopPropagation();
                e.preventDefault()
            });
            obj.on('dragover', function(e) {
                e.stopPropagation();
                e.preventDefault()
            });
            obj.on('drop', function(e) {
                e.preventDefault();
                images_upload(e.originalEvent.dataTransfer.files)
            })
        });
        var url_upload = function() {
            var urls = $("#urls").val();
            var url_arr = urls.split("\n");
            if (urls == "" || url_arr.length == 0) {
                alert("请贴入需要上传的网络图片地址.");
                return
            }
            $('#url_upload_model').modal('hide');
            $('.mselector > button')[1].innerHTML = '上传中...';
            for (var i = 0; i < url_arr.length; i++) {
                $.ajax({
                    url: 'https://api.yum6.cn/sinaimg.php',
                    type: 'GET',
                    data: {
                        img: url_arr[i]
                    },
                    cache: false,
                    dataType: 'json',
                    success: function(data) {
                        if (typeof data.pid != 'undefined') {
                            $('#url-res-txt').append('https://ww1.sinaimg.cn/large/'+data.pid + '.jpg\n');
                            $('.mselector > button')[1].innerHTML = '成功 ' + (i + 1) + '/' + url_arr.length;
                            var apc = "<img src='https://ww2.sinaimg.cn/large/" + data.pid + ".jpg'><p>https://ww1.sinaimg.cn/large/" + data.pid + ".jpg</p><br>";
                            $('.preview').css('display', 'block');
                            $(".preview>hr").after(apc)
                        } else {
                            $('.mselector > button')[1].innerHTML = '第' + (i + 1) + '张上传失败'
                        } if (typeof data.pid != 'undefined') {
                            $('.mselector > button')[1].innerHTML = '上传成功'
                        } else {
                            $('.mselector > button')[1].innerHTML = '上传失败';
                            $('#url-res-txt').append(data.error_msg + '\n');
                            alert(data.error_msg)
                        }
                    },
                    error: function(XMLResponse) {
                        alert("error:" + XMLResponse.responseText)
                    }
                })
            }
        };
        var images_upload = function(files) {
            var flag = 0;
            $('textarea').empty();
            $(files).each(function(key, value) {
                $('.mselector > button')[0].innerHTML = '上传中...';
                image_form = new FormData();
                image_form.append('file', value);
              	console.log(image_form);
                $.ajax({
                    url: 'https://api.yum6.cn/sinaimg.php?type=multipart',
                    type: 'POST',
                    data: image_form,
                    mimeType: 'multipart/form-data',
                    contentType: false,
                    cache: false,
                    processData: false,
                    dataType: 'json',
                    success: function(data) {
                        flag++;
                        if (typeof data.pid != 'undefined') {
                            $('#url-res-txt').append('https://ww1.sinaimg.cn/large/'+data.pid + '.jpg\n');
                            $('.mselector > button')[0].innerHTML = '成功 ' + flag + '/' + files.length;
                            var apc = "<img src='https://ww1.sinaimg.cn/large/" + data.pid + ".jpg'><p>https://ww1.sinaimg.cn/large/" + data.pid + ".jpg</p><br>";
                            $('.preview').css('display', 'block');
                            $(".preview>hr").after(apc)
                        } else {
                            $('.mselector > button')[0].innerHTML = '第' + flag + '张上传失败'
                        } if (flag == $("input[type='file']")[0].files.length) {
                            if (typeof data.pid != 'undefined') {
                                $('.mselector > button')[0].innerHTML = '上传成功'
                            } else {
                                $('.mselector > button')[0].innerHTML = '上传失败';
                                $('#url-res-txt').append(data.error_msg + '\n');
                                alert(data.error_msg)
                            }
                        }
                    },
                    error: function(XMLResponse) {
                        alert("error:" + XMLResponse.responseText)
                    }
                })
            })
        };
        document.onpaste = function(e) {
            var data = e.clipboardData;
            for (var i = 0; i < data.items.length; i++) {
                var item = data.items[i];
                if (item.kind == 'file' && item.type.match(/^image\//i)) {
                    var blob = item.getAsFile();
                    images_upload(blob)
                }
            }
        }

    </script>


    </body></html><meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />